<template>
	<view class="content">
		<web-view class="web-view" :src="src"></web-view>
		<view class="form-content">
			<u-cell-group :border="false">
				<u-cell title="创建时间" :value="$util.timestampToTime(landInfo.createTime)"></u-cell>
				<u-cell title="投入品" :value="landInfo.inputName"></u-cell>
				<u-cell title="作物产量(斤/亩)" :value="landInfo.cropYield"></u-cell>
				<u-cell title="地块编码" :value="landInfo.landCode"></u-cell>
				<u-cell title="土地面积" :value="landInfo.landArea"></u-cell>
				<u-cell title="土壤信息" :value="$util.getDictData('land_information',landInfo.landInformation)"></u-cell>
				<u-cell title="病虫害防治" :value="$util.getDictData('pests_diseases',landInfo.pestsDiseases)"></u-cell>
				<u-cell title="种植周期(月)" :value="landInfo.plantingCycle"></u-cell>
				<u-cell title="种植物名称" :value="landInfo.plantingName"></u-cell>
				<u-cell title="种植时间" :value="$util.timestampToTime(landInfo.plantingTime)"></u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	let wv; //计划创建的webview
  import {getLandOne} from "@/api/farmer/land.js";

  export default {
		data() {
			return {
				landInfo: {},
				src: '',
				id: '',
			}
		},
		methods: {
			async getLandOneFn() {
				let id = uni.getStorageSync('userInfo').farmerId;
				let res = await getLandOne({
					id
				})
				res = res.plantingInformationList.find(item => item.id == this.id)
				this.src = '/hybrid/html/openlayers.html?data=' + JSON.stringify(res);
				this.landInfo = res;
			}
		},
		onReady() {
			// #ifdef APP-PLUS
			const currentWebview = this.$scope
				.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
			setTimeout(function() {
				wv = currentWebview.children()[0];
				wv.setStyle({
					top: 70,
					height: uni.getSystemInfoSync().windowWidth
				})
			}, 1000); //如果是页面初始化调用时，需要延时一下
			// #endif
		},
		onLoad(option) {
			this.id = option.id
			this.getLandOneFn();

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;

		.web-view {
			width: 100vw;
			height: 100vh;
		}

		.form-content {
			padding-top: 100vw;
			background-color: #fff;
		}

	}
</style>
